package com.hpf.lease.web.admin.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hpf.lease.common.result.Result;
import com.hpf.lease.model.bean.UserInfo;
import com.hpf.lease.web.admin.dto.UserSearchSubmitDto;
import com.hpf.lease.web.admin.service.UserInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/user")
@Tag(name = "用户信息管理模块")
public class UserController {
    @Resource
    UserInfoService userInfoService;
    @PostMapping("/updateStatusById")
    @Operation(summary = "根据用户id更新状态")
    public Result<Object> updateStatusById(@RequestParam long id , @RequestParam Integer status){
        return Result.build(userInfoService.update(Wrappers.lambdaUpdate(UserInfo.class)
                .eq(UserInfo::getId , id)
                .set(UserInfo::getStatus , status)));
    }
    @GetMapping("/page")
    @Operation(summary = "分页查询用户信息")
    public Result<Page<UserInfo>> getPage(UserSearchSubmitDto submitDto){
        return Result.ok(userInfoService.getPageItem(submitDto));
    }
}
